package com.tedu.charging.service.device.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tedu.charging.common.pojo.po.GunStationPO;
import com.tedu.charging.service.device.dao.GunStationMapper;
import com.tedu.charging.service.device.pojo.po.GunInfoPO;
import com.tedu.charging.common.pojo.vo.GunInfoVO;
import com.tedu.charging.service.device.service.IGunInfoService;
import com.tedu.charging.service.device.dao.GunInfoMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author zjj
* @description 针对表【charging_gun_info】的数据库操作Service实现
* @createDate 2023-08-30 17:32:54
*/
@Service
public class GunInfoServiceImpl extends ServiceImpl<GunInfoMapper, GunInfoPO>
    implements IGunInfoService {

    @Autowired
    GunInfoMapper gunInfoMapper;
    @Autowired
    GunStationMapper gunStationMapper;

    @Override
    public List<GunInfoVO> selectByStationId(Integer stationId){
        List<GunInfoPO> poList = gunInfoMapper.selectByStationId(stationId);
        ArrayList voList = new ArrayList();
        for (GunInfoPO gunInfoPO:poList){
            GunInfoVO gunInfoVO = new GunInfoVO();
            BeanUtils.copyProperties(gunInfoPO,gunInfoVO);
            voList.add(gunInfoVO);
        }
        return  voList;
    }

    @Override
    public GunInfoVO selectByGunId(Integer gunId) {
        GunInfoPO gunInfoPO = gunInfoMapper.selectById(gunId);
        GunInfoVO gunInfoVO = new GunInfoVO();
        BeanUtils.copyProperties(gunInfoPO,gunInfoVO);
        return  gunInfoVO;
    }

    @Override
    public GunStationPO selecStationtByGunId(Integer gunId) {
        return gunStationMapper.selectByGunId(gunId);
    }
}




